/*
 * Variable.cpp
 *
 *  Created on: 2 июн. 2022 г.
 *      Author: nikita
 */

#include "MVariable.h"

namespace STC_calc {

MVariable::MVariable(const std::string& name, const long double min, const long double max, const long double steps)
{
	number_of_steps = steps;
	range.first = min;
	range.second = max;
	variable_name = name;
	curr_step = (max-min)/steps;
}

MVariable::MVariable(const MVariable&& a)
{
	number_of_steps = a.number_of_steps;
	range = a.range;
	variable_name = a.variable_name;
	curr_step = a.curr_step;
}

MVariable::~MVariable() {
}

long double MVariable::operator()()
{
	return get_value(0);
}

void MVariable::operator =(const MVariable& A)
{
	number_of_steps = A.number_of_steps;
	range = A.range;
	variable_name = A.variable_name;
	curr_step = A.curr_step;
}


std::string MVariable::name()
{
	return variable_name;
}

long double MVariable::get_value(const int step)
{
	if (step >= number_of_steps) throw(RuntimeErrorClass("Error: in MVariable calling get_value with step > steps", Enums::fatal));
	return range.first + curr_step*step;
}

} /* namespace STC_calc */
